//Source file: D:\\test\\com\\ce\\pms\\house\\model\\HouseDomain.java

package com.ce.pms.house.model;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Where;

import com.ce.pms.common.model.SysInfo;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.exception.BusinessException;

/**
 * 实体名称：房屋 关联表:HM_HOUSE
 *
 * @author Adama Yue
 *
 */
@Entity
@Table(name = "HM_HOUSE")
@PrimaryKeyJoinColumn(name = "HOUSE_ID")
public class HouseDomain extends Product {
	/**
	 * 对应管理房
	 */

//	@Transient
//	CoalitionHouseDomain mergeCoalition = null;
//	@Transient
//	CoalitionHouseDomain sharePropertyCoalition = null;
	 /**
	 * 楼栋ID
	 * 检索策略:lazy=true
	 */
	@ManyToOne(cascade={},fetch=FetchType.LAZY)
	@JoinColumn(name="BUILDING_ID",nullable=true)
	 private BuildingDomain building;

	/**
	 * 房号
	 */
	@Column(name = "HOUSE_NUMBER", nullable = false, insertable = true, updatable = true, length = 36)
	private String houseNumber;

	 /**
	 * 户型编号
	 */
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="HOUSE_PLAN_ID",nullable=true)
	 private HousePlan housePlan;

	/**
	 * 建筑面积
	 */
	@Column(name = "BUILD_SIZE", nullable = true, precision = 12, scale = 2)
	private BigDecimal buildSize;

	/**
	 * 套内面积
	 */
	@Column(name = "INNER_SIZE", nullable = true, precision = 12, scale = 2)
	private BigDecimal innerSize;

	/**
	 * 公摊面积
	 */
	@Column(name = "PUBLIC_SIZE", nullable = true, precision = 12, scale = 2)
	private BigDecimal publicSize;

	/**
	 * 房屋状态
	 */
	@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
	@JoinColumn(name = "SYS_REF_ID", nullable = true)
	private SysrefcodeDO status;

	/***
	 * (房屋)装修状态
	 */
	@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
	@JoinColumn(name ="SYS_REF_ID1", nullable = true)
	private SysrefcodeDO subStatuz;

	/**
	 * 备注
	 */
	@Column(name = "REMARK", nullable = true, insertable = true, updatable = true, length = 500)
	private String remark;
	/**
	 * 是否管理房
	 */
	@Column(name="IS_VIRTUAL",nullable=false,length=1)
	private String isVirtual;

	/**
	 * @roseuid 484F3FA40242
	 */
	public HouseDomain() {
	}

	public HouseDomain(Long keyword){
		super(keyword);
	}

	/**
	 * use for proright house mini constructor
	 *
	 * @param houseNumber
	 *            房号
	 * @param buildSize
	 *            建筑面积
	 * @param innerSize
	 *            套内面积
	 * @param publicSize
	 *            公摊面积
	 * @param status
	 *            房屋状态
	 * @param remark
	 *            备注
	 * @param sysInfo
	 * 			  是否管理房
	 * @param sysInfo
	 *            系统新增和修改信息
	 */
	public HouseDomain(String houseNumber, BigDecimal buildSize,
			BigDecimal innerSize, BigDecimal publicSize, SysrefcodeDO status,
			String remark,String isVirtual, SysInfo sysInfo) {
		super(sysInfo);
		this.houseNumber = houseNumber;
		this.buildSize = buildSize;
		this.innerSize = innerSize;
		this.publicSize = publicSize;
		this.status = status;
		this.isVirtual = isVirtual;
		this.remark = remark;
	}

	/**
	 * 罗军林编写，仅适用特殊方法
	 * @param keyword
	 * @param buildSize
	 * @param innerSize
	 */
	public HouseDomain(Long keyword,BigDecimal buildSize,BigDecimal innerSize){
		this.setKeyword(keyword);
		this.buildSize = buildSize;
		this.innerSize = innerSize;
	}

	/**
	 * used for virtual house mini constructor
	 * @param houseNumber 管理房号
	 * @param isVirtual   是否管理房
	 * @param sysInfo     系统信息
	 */
	public HouseDomain(String houseNumber, String isVirtual, SysInfo sysInfo) {
		super(sysInfo);
		this.houseNumber = houseNumber;
		this.isVirtual = isVirtual;
	}

	/***************************************************************************
	 * Accessors and Modifiers
	 **************************************************************************/
	public BigDecimal getBuildSize() {
		return buildSize;
	}

	public void setBuildSize(BigDecimal buildSize) {
		this.buildSize = buildSize;
	}

	public String getHouseNumber() {
		return houseNumber;
	}

	public void setHouseNumber(String houseNumber) {
		this.houseNumber = houseNumber;
	}

	public BigDecimal getInnerSize() {
		return innerSize;
	}

	public void setInnerSize(BigDecimal innerSize) {
		this.innerSize = innerSize;
	}

	public BigDecimal getPublicSize() {
		return publicSize;
	}

	public void setPublicSize(BigDecimal publicSize) {
		this.publicSize = publicSize;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public SysrefcodeDO getStatus() {
		return status;
	}

	public void setStatus(SysrefcodeDO status) {
		this.status = status;
	}

//	public CoalitionHouseDomain getMergeCoalition() {
//		getCoalition();
//
//		if ((getCoalition()!= null)
//				&& "001".equals(this.getCoalition().getCoalitionType().getCode())) {
//			mergeCoalition = coalition;
//		} else {
//			mergeCoalition = null;
//		}
//		return mergeCoalition;
//	}

	public BuildingDomain getBuilding() {
		return building;
	}

	public void setBuilding(BuildingDomain building) {
		this.building = building;
	}

	/**
	 * 功能描述: 获取housePlan
	 *
	 * @author 付湘辉
	 * Created on:2008-7-1
	 *
	 * 修改原因：
	 * @return 返回结果
	 */
	public HousePlan getHousePlan() {
		return housePlan;
	}

	/**
	 * 功能描述: 设置housePlan
	 *
	 * @author 付湘辉
	 * Created on:2008-7-1
	 *
	 * 修改原因：
	 * @param housePlan the housePlan to set
	 */
	public void setHousePlan(HousePlan housePlan) {
		this.housePlan = housePlan;
	}

	public String getIsVirtual() {
		return isVirtual;
	}

	public void setIsVirtual(String isVirtual) {
		this.isVirtual = isVirtual;
	}

	/**
	 *
	 * 功能描述: 判断必填项是否有值
	 *
	 * @author 付湘辉
	 * Created on:2008-7-11
	 *
	 * 修改原因：
	 * @return void 返回结果
	 */
	public void checkRequiredField(){
		if (this.building == null
				|| this.houseNumber == null
				|| this.housePlan == null
				|| this.publicSize == null
				|| this.innerSize == null
				|| this.buildSize == null) {
			throw new BusinessException("common:mustFill_null_exception",
					BusinessException.WARNING);
		}
	}

	/**
	 * 功能描述: 是否是管理房 <br>
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-9-8  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public Boolean isVirtualHouse(){
		if (SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(this.isVirtual)) {
			return true;
		}
		return false;
	}

	public SysrefcodeDO getSubStatuz() {
		return subStatuz;
	}

	public void setSubStatuz(SysrefcodeDO subStatuz) {
		this.subStatuz = subStatuz;
	}


//	public CoalitionHouseDomain getCoalition() {
//		return coalition;
//	}
//
//	public void setCoalition(CoalitionHouseDomain coalition) {
//		this.coalition = coalition;
//	}


}
